﻿// JavaScript Document

$(document).ready(function () {
	$("#close_a").click(
		function(){
			$("#yulan").hide();
		});
	
	$("#website2").hide();
	$("#website3").hide();
	$("li.a").mouseover(
		function(){
			x = getElementPos(this).x + 162;
			y = getElementPos(this).y - 26;
			x = x + "px";
			y = y + "px";
			$(this).css({"background":"#dfbdf1","fontWeight":"bold","color":"#333"});
			//$(this).css("background","#FFFFFF");
			$("div.b1").hide();
			$(this).find('div.b1').show();
			$(this).find('div.b1').css({"top":y,"left":x });
		}
	);
	$("li.a").mouseout(
		function(){
			$(this).css({"background":"#f1e7f4","fontWeight":"normal","color":"#614c88"});
			//$(this).css("background","#CCCCCC");
			$(this).find('div.b1').hide();
			$("div.b1").hide();
		}
	);

	$("li.right_a").mouseover(
		function(){
			x = getElementPos(this).x + -630;
			y = getElementPos(this).y - 26;
			x = x + "px";
			y = y + "px";
			$(this).css({"background":"#dfbdf1","fontWeight":"bold","color":"#333"});
			//$(this).css("background","#FFFFFF");
			$("div.right_b1").hide();
			$(this).find('div.right_b1').show();
			$(this).find('div.right_b1').css({"top":y,"right":x });
		}
	);
	$("li.right_a").mouseout(
		function(){
			$(this).css({"background":"#f1e7f4","fontWeight":"normal","color":"#614c88"});
			//$(this).css("background","#CCCCCC");
			$(this).find('div.right_b1').hide();
			$("div.right_b1").hide();
		}
	);

	$("ul.sheqian2").find("a").mouseover(
		function(){
			$("div.sheqianbody").children().hide();
			//$("ul.sheqian2").children().attr("class","");
			$("#tousu").attr("class","");
			$("#noweb").attr("class","");
			$("#liang").attr("class","");
			$("#youhui").attr("class","");
			$("#tuangou").attr("class","");
			$(this).attr("class","active");
			str = $(this).attr("id");
			str = "#sq-" + str;
			$(str).show();
		}
	);
	ajax_load("#website1" ,APP+"/Index/zhuzhuangtu");
});

function GetYulan()
{
	$('img.tttt').fadeTo("fast",0.5);
	$('img.tttt').hover(
			function() {$(this).fadeTo("fast", 1);},
			function() {$(this).fadeTo("fast", 0.5);}
	);
	$("img.tttt").click(
			function(){
				x = getElementPos(this).x + 30;
				y = getElementPos(this).y - 125;
				x = x + "px";
				y = y + "px";
				//$(this).css({"background":"#dfbdf1","fontWeight":"bold","color":"#333"});
				//$("#yulan").hide();
				$("#yulan").css({"top":y,"left":x });
				$("#yulan").show();
				$("#close_a").show();
				n = $(this).attr("id");
				$("#ajyulan").load(APP+"/Op/yulan",{siteid : n},function(){});
			}
		);
}

function CloseWebsite2()
{
	$("#website1").show();
	$("#website2").hide();
}

function getElementPos(el) {
	var ua = navigator.userAgent.toLowerCase();
	var isOpera = (ua.indexOf('opera') != -1);
	var isIE = (ua.indexOf('msie') != -1 && !isOpera); // not opera spoof
	//var el = document.getElementById(elementId);
	if(el.parentNode === null || el.style.display == 'none') {
		return false;
	}
	var parent = null;
	var pos = [];
	var box;
	if(el.getBoundingClientRect)	//IE
	{
		box = el.getBoundingClientRect();
		var scrollTop = Math.max(document.documentElement.scrollTop, document.body.scrollTop);
		var scrollLeft = Math.max(document.documentElement.scrollLeft, document.body.scrollLeft);
		return {x:box.left + scrollLeft, y:box.top + scrollTop};
	}
	else if(document.getBoxObjectFor)	// gecko
	{
		box = document.getBoxObjectFor(el); 
		var borderLeft = (el.style.borderLeftWidth)?parseInt(el.style.borderLeftWidth):0; 
		var borderTop = (el.style.borderTopWidth)?parseInt(el.style.borderTopWidth):0; 
		pos = [box.x - borderLeft, box.y - borderTop];
	}
	else	// safari & opera
	{
		pos = [el.offsetLeft, el.offsetTop];
		parent = el.offsetParent;
		if (parent != el) {
			while (parent) {
				pos[0] += parent.offsetLeft; 
				pos[1] += parent.offsetTop; 
				parent = parent.offsetParent;
			}
		}
		if (ua.indexOf('opera') != -1 || ( ua.indexOf('safari') != -1 && el.style.position == 'absolute' )) { 
			pos[0] -= document.body.offsetLeft;
			pos[1] -= document.body.offsetTop;
		}
	}
	if (el.parentNode) { 
		parent = el.parentNode;
	} else {
		parent = null;
	}
	while (parent && parent.tagName != 'BODY' && parent.tagName != 'HTML') { // account for any scrolled ancestors
		pos[0] -= parent.scrollLeft;
		pos[1] -= parent.scrollTop;
		if (parent.parentNode) {
			parent = parent.parentNode;
		} else {
			parent = null;
		}
	}
	return {x:pos[0], y:pos[1]};
}

//刷新验证码
function fleshVerify(){ 
	//重载验证码
	var timenow = new Date().getTime();
	$("#verifyImg").attr("src" , URL+'/verify/'+timenow);
}